

function addArduinoCod(Blockly) {




    Blockly.Arduino['EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = function (block) {
        let in1 = this.getFieldValue('in1');
        let in2 = this.getFieldValue('in2');
        let in3 = this.getFieldValue('in3');
        let in4 = this.getFieldValue('in4');
        let speed1 = Blockly.Arduino.valueToCode(this, 'speed1', Blockly.Arduino.ORDER_ATOMIC);
        let speed2 = Blockly.Arduino.valueToCode(this, 'speed2', Blockly.Arduino.ORDER_ATOMIC);

        Blockly.Arduino.definitions_['include_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = ``;
        Blockly.Arduino.definitions_['define_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = `#define IN1_PIN${in1} ${in1}\r\n#define IN2_PIN${in2} ${in2}\r\n#define IN3_PIN${in3} ${in3}\r\n#define IN4_PIN${in4} ${in4}`;
        Blockly.Arduino.definitions_['setup_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = `pinMode(IN1_PIN${in1}, OUTPUT);\r\n  digitalWrite(IN1_PIN${in1}, LOW);\r\n  pinMode(IN2_PIN${in2}, OUTPUT);\r\n  digitalWrite(IN2_PIN${in2}, LOW);\r\n  pinMode(IN3_PIN${in3}, OUTPUT);\r\n  digitalWrite(IN3_PIN${in3}, LOW);\r\n  pinMode(IN4_PIN${in4}, OUTPUT);\r\n  digitalWrite(IN4_PIN${in4}, LOW);`;
        return `analogWrite(IN1_PIN${in1}, LOW);\r\nanalogWrite(IN2_PIN${in2}, ${speed1});\r\nanalogWrite(IN3_PIN${in3}, ${speed2});\r\nanalogWrite(IN4_PIN${in4}, LOW);\r\n`;
    }

    //     return Blockly;
    // }

    Blockly.Arduino['EXT_TWO_WAY_MOTOR_BLOCK_STOP_1607594494606'] = function (block) {
        let in1 = this.getFieldValue('in1');
        let in2 = this.getFieldValue('in2');
        let in3 = this.getFieldValue('in3');
        let in4 = this.getFieldValue('in4');
        // let speed1 = Blockly.Arduino.valueToCode(this, 'speed1', Blockly.Arduino.ORDER_ATOMIC);
        // let speed2 = Blockly.Arduino.valueToCode(this, 'speed2', Blockly.Arduino.ORDER_ATOMIC);

        Blockly.Arduino.definitions_['include_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = ``;
        Blockly.Arduino.definitions_['define_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = `#define IN1_PIN${in1} ${in1}\r\n#define IN2_PIN${in2} ${in2}\r\n#define IN3_PIN${in3} ${in3}\r\n#define IN4_PIN${in4} ${in4}`;
        Blockly.Arduino.definitions_['setup_EXT_TWO_WAY_MOTOR_BLOCK_1607594494605'] = `pinMode(IN1_PIN${in1}, OUTPUT);\r\n  digitalWrite(IN1_PIN${in1}, LOW);\r\n  pinMode(IN2_PIN${in2}, OUTPUT);\r\n  digitalWrite(IN2_PIN${in2}, LOW);\r\n  pinMode(IN3_PIN${in3}, OUTPUT);\r\n  digitalWrite(IN3_PIN${in3}, LOW);\r\n  pinMode(IN4_PIN${in4}, OUTPUT);\r\n  digitalWrite(IN4_PIN${in4}, LOW);`;
        return `analogWrite(IN1_PIN${in1}, 255);\r\nanalogWrite(IN2_PIN${in2}, 255);\r\nanalogWrite(IN3_PIN${in3}, 255);\r\nanalogWrite(IN4_PIN${in4}, 255);\r\n`;
    }

    return Blockly;
}

module.exports = addArduinoCod;

